package com.jackiechan.day18;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Test_Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);
        System.out.println("等待");
        Socket socket = ss.accept();
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
        while (true) {
            try {
                System.out.print((char) in.read());
                while (in.available() != 0) {
                    System.out.print((char) in.read());
                }
                System.out.println("\n洞拐洞拐,收到请回答: ");
            } catch (IOException e) {
                System.out.println("客户未发送信息");
                break;
            }
//            System.out.print("请应答:");
//            String msg = new Scanner(System.in).nextLine();
    //            if ("quit".equals(msg))break;
//            out.write(msg.getBytes());
//            System.out.println("返回成功");
        }
        ss.close();
    }
}

